package com.config;

import org.springframework.context.annotation.Bean;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * request转换成 Multipart request的配置bean 如果没有spring 不会转
 */
public class FileUploadConfig {
    //识别到提交数据的类型为 多部分数据（文件） 就使用这个bean来处理
    @Bean("multipartResolver")
    public CommonsMultipartResolver getMultipartResolver(){
        CommonsMultipartResolver commonsMultipartResolver  = new CommonsMultipartResolver();
        commonsMultipartResolver.setDefaultEncoding("utf-8");
        commonsMultipartResolver.setMaxInMemorySize(2*1024*1024);
        return commonsMultipartResolver;
    }
}
